package br.edu.fcsl.persistencia;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;


public class FabricaConexoes {
	
	private static Connection conn;

	public static Connection getConnection()  {
		 
		
		if (conn == null){
			//inicializa o conn
			//passo 1: Regitrar o Driver do BD
			try {
				Class.forName("com.mysql.jdbc.Driver");
				try {
					conn = DriverManager.getConnection("jdbc:mysql://localhost/db_ecomerce", "root", "");
				} catch (SQLException e) {
					// TODO Auto-generated catch block
					e.printStackTrace();
				}
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} // buscando conexão com mysql
			//passo 2: Pedir conexão
			
			
			
		}
	return conn;
	}		
}